package com.h3c.tj_nsh.UI.Fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.h3c.tj_nsh.MyApplication;


/**
 * Time: 2016/4/23.
 * Author:Chen  .
 */
public abstract class BaseFragment extends Fragment {

    private MyApplication mMyApplication;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(getLayoutResId(), container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }



    /***
     * 获取SWMApplication
     *
     * @return
     */
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mMyApplication = (MyApplication) context.getApplicationContext();
    }

    protected MyApplication getApplication() {
        return mMyApplication;
    }

    /***
     * 子类实现方法，提供fragment布局的资源id
     *
     * @return
     */
    protected abstract int getLayoutResId();


}
